﻿    /*----------------------------------------------------
 * Author : Tharinduni Udugamasuriya
 * Date : June 2014
 * GlobalVariables : To manage Global Variables
 ---------------------------------------------------*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Practices.Unity;
using Microsoft.Practices.Unity.Configuration;
using System.Configuration;
using System.Data.SqlClient;

namespace DSPL.Contracts.Common
{
    public static class GlobalVariables
    {

        static string machineName;
        static IUnityContainer globalUnityContainer;
        static List<string> masterInsertIgnoreList;
        static List<string> masterUpdateIgnoreList;
        static List<string> masterDeleteIgnoreList;
        static List<string> masterLogIgnoreList;
        static string _loggedInUser = "DSPL";

        public static string UserName { get; set; }
        //{
        //    get { return new RegistryManager().FinUser; }
        //    set { username = new RegistryManager().FinUser; }
        //}

        public static string Password { get; set; }
        //{
        //    get { return new RegistryManager().FinPassword; }
        //    set { password = new RegistryManager().FinPassword; }
        //}

        //public static string Connectionstring
        //{
        //    get { return new RegistryManager().FinConStr; }
        //    set { connectionString = new RegistryManager().FinConStr; }
        //}


        public static string Connectionstring= ConfigurationManager.ConnectionStrings["Global"].ConnectionString;

        
        public static IUnityContainer GlobalUnityContainer
        {
            get
            {
                globalUnityContainer = new UnityContainer();
                return globalUnityContainer.LoadConfiguration("customContainer");
            }
        }

        public static string Database { get; set; }
        //{
        //    get { return new RegistryManager().FinDb; }
        //    set { database = new RegistryManager().FinDb; }
        //}

        public static string Server { get; set; }
        //{
        //    get { return new RegistryManager().FinServer; }
        //    set { server = new RegistryManager().FinServer; }
        //}

        public static string MachineName
        {
            get { return Environment.MachineName + "#" + Environment.UserName; }
            set { machineName = Environment.MachineName + "#" + Environment.UserName; }
        }

        public const string ApplicationName = "FiNAC - Global";

        public static List<string> MasterInsertIgnoreList
        {
            get
            {
                masterInsertIgnoreList = new List<string> ();
                masterInsertIgnoreList.Add("RECORDID");
                masterInsertIgnoreList.Add("PK");
                masterInsertIgnoreList.Add("TIMESTAMP_COLUMN");
                masterInsertIgnoreList.Add("ADDUSER");
                masterInsertIgnoreList.Add("ADDDATE");
                masterInsertIgnoreList.Add("ADDMACH");
                return masterInsertIgnoreList;
            }
        }

        public static List<string> MasterUpdateIgnoreList
        {
            get
            {
                masterUpdateIgnoreList = new List<string>();
                masterUpdateIgnoreList.Add("RECORDID");
                masterUpdateIgnoreList.Add("TIMESTAMP_COLUMN");
                masterUpdateIgnoreList.Add("ADDUSER");
                masterUpdateIgnoreList.Add("ADDDATE");
                masterUpdateIgnoreList.Add("ADDMACH");
                return masterUpdateIgnoreList;
            }
        }

        public static List<string> MasterDeleteIgnoreList
        {
            get 
            {
                masterDeleteIgnoreList = new List<string>();
                masterDeleteIgnoreList.Add("RECORDID");
                masterDeleteIgnoreList.Add("TIMESTAMP_COLUMN");
                masterDeleteIgnoreList.Add("ADDUSER");
                masterDeleteIgnoreList.Add("ADDDATE");
                masterDeleteIgnoreList.Add("ADDMACH");
                return masterDeleteIgnoreList; 
            }
        }

        public static List<string> MasterLogIgnoreList
        {
            get 
            {
                masterLogIgnoreList = new List<string>();
                masterLogIgnoreList.Add("RECORDID");
                masterLogIgnoreList.Add("DELUSER");
                masterLogIgnoreList.Add("TIMESTAMP_COLUMN");
                masterLogIgnoreList.Add("DELDATE");
                masterLogIgnoreList.Add("DELMACH");
                masterLogIgnoreList.Add("DELTYPE"); 
                return masterLogIgnoreList;
            }
        }

        public static string LoggedInUser
        {
            get { return _loggedInUser; }
            set { _loggedInUser = value; }
        }

        public static string BaseCurrency
        {
            get { return ConfigurationManager.AppSettings["BaseCurrency"].ToString().Trim(); }
        }

        public static string CompanyName
        {
            get { return ConfigurationManager.AppSettings["CompanyName"].ToString().Trim(); }
        }

        public static string Address
        {
            get { return ConfigurationManager.AppSettings["Address"].ToString().Trim(); }
        }

        public static string ContactDetails
        {
            get { return ConfigurationManager.AppSettings["ContactDetails"].ToString().Trim(); }
        }

        public static string CopyRight
        {
            get { return ConfigurationManager.AppSettings["CopyRight"].ToString().Trim(); }
        }

        public static string SystemCurrency
        {
            get { return ConfigurationManager.AppSettings["SystemCurrency"].ToString().Trim(); }
        }


        public static int CurValDecimalPoints
        {
            get { return Convert.ToInt32(ConfigurationManager.AppSettings.Get("CurValDecimalPoints")); }
        }

        public static int RefNoLength
        {
            get { return Convert.ToInt32(ConfigurationManager.AppSettings.Get("RefNoLength")); }
        }

        public static int NumberofRecodsPerPage { get { return Convert.ToInt32(ConfigurationManager.AppSettings.Get("NumberofRecodsPerPage")); } }

        public static string AttachmentFolderPath
        {
            get
            {
                return ConfigurationManager.AppSettings.Get("AttachmentFolderPath").ToString().Trim();
            }
        }
    }
}
